package cn.iocoder.yudao.module.digital.dal.mysql.competition;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.digital.controller.admin.competition.vo.CompetitionPageReqVO;
import cn.iocoder.yudao.module.digital.dal.dataobject.competition.CompetitionDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 竞赛 Mapper
 *
 * @author admin
 */
@Mapper
public interface CompetitionMapper extends BaseMapperX<CompetitionDO> {

    default PageResult<CompetitionDO> selectPage(CompetitionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CompetitionDO>()
                .likeIfPresent(CompetitionDO::getName, reqVO.getName())
                .eqIfPresent(CompetitionDO::getType, reqVO.getType())
                .eqIfPresent(CompetitionDO::getOrganizer, reqVO.getOrganizer())
                .likeIfPresent(CompetitionDO::getOrganizerOther, reqVO.getOrganizerOther())
                .eqIfPresent(CompetitionDO::getLevel, reqVO.getLevel())
                .eqIfPresent(CompetitionDO::getAuthor, reqVO.getAuthor())
                .likeIfPresent(CompetitionDO::getMember, reqVO.getMember())
                .eqIfPresent(CompetitionDO::getCompetitionOrganizer, reqVO.getCompetitionOrganizer())
                .eqIfPresent(CompetitionDO::getRate, reqVO.getRate())
                .betweenIfPresent(CompetitionDO::getCompetitionTime, reqVO.getCompetitionTime())
                .eqIfPresent(CompetitionDO::getRank, reqVO.getRank())
                .betweenIfPresent(CompetitionDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(CompetitionDO::getReserved1, reqVO.getReserved1())
                .likeIfPresent(CompetitionDO::getReserved2, reqVO.getReserved2())
                .orderByDesc(CompetitionDO::getId));
    }

}